<template>
    <svg
        aria-hidden="true"
        :width="formatSize"
        :height="formatSize"
    >
        <use :href="symbolId" :color="color" />
    </svg>
</template>

<script setup>
import { computed } from 'vue'

defineOptions({
    name: 'SvgIcon'
})

const props = defineProps({
    prefix: {
        type: String,
        default: 'icon'
    },
    name: {
        type: String,
        required: true
    },
    color: {
        type: String,
        default: '#000'
    },
    size: {
        type: [String, Number],
        default: 25
    }
})

const symbolId = computed(() => `#${props.prefix}-${props.name}`)
const formatSize = computed(() => parseFloat(props.size))
</script>

<style lang="scss" scoped>
svg {
    box-sizing: border-box;
}
</style>